import torch

loss = torch.nn.BCEWithLogitsLoss()
input = torch.tensor([[0.48], [0.94], [0.2]], requires_grad=True)
print(input)
target = torch.tensor([[1.0], [0.0], [1.0]])
print(target)
out_loss = loss(input, target)
print(out_loss)
out_loss.backward()

loss = torch.nn.BCELoss()
input = torch.tensor([[0.48], [0.94], [0.2]], requires_grad=True)
print(input)
out_loss = loss(input, target)
print(out_loss)
out_loss.backward()



loss = torch.nn.BCEWithLogitsLoss()
input = torch.tensor([[1.48], [1.94], [1.2]], requires_grad=True)
print(input)
out_loss = loss(input, target)
print(out_loss)
out_loss.backward()

loss = torch.nn.BCELoss()
input = torch.tensor([[1.48], [1.94], [1.2]], requires_grad=True)
m =torch.nn.Sigmoid()
print(input)
input = m(input)
out_loss = loss(input, target)
print(out_loss)
out_loss.backward()

'''
tensor([[ 0.4800],
        [ 0.9400],
        [ 0.2000]])
tensor([[ 1.],
        [ 0.],
        [ 1.]])
tensor(0.7832)
tensor([[ 0.4800],
        [ 0.9400],
        [ 0.2000]])
tensor(1.7189)
tensor([[ 1.4800],
        [ 1.9400],
        [ 1.2000]])
tensor(0.8475)
tensor([[ 1.4800],
        [ 1.9400],
        [ 1.2000]])
tensor(0.8475)
'''